- page_title "里程碑"
- header_title group_title(@group, "里程碑", group_milestones_path(@group))

%h3.page-title
  新里程碑

%p.light
  将会给每一个选择的项目创建里程碑
%hr

= form_for @milestone, url: group_milestones_path(@group), html: { class: 'form-horizontal milestone-form common-note-form js-quick-submit js-requires-input' }  do |f|
  .row
    - if @milestone.errors.any?
      #error_explanation
        .alert.alert-danger
          %ul
            - @milestone.errors.full_messages.each do |msg|
              %li
                = msg

    .col-md-6
      .form-group
        = f.label :title, "标题", class: "control-label"
        .col-sm-10
          = f.text_field :title, maxlength: 255, class: "form-control", required: true, autofocus: true
      .form-group.milestone-description
        = f.label :description, "描述", class: "control-label"
        .col-sm-10
          = render layout: 'projects/md_preview', locals: { preview_class: "md-preview" } do
            = render 'projects/zen', f: f, attr: :description, classes: 'note-textarea', placeholder: '撰写里程碑描述...'
            .clearfix
            .error-alert
      .form-group
        = f.label :projects, "项目", class: "control-label"
        .col-sm-10
          = f.collection_select :project_ids, @group.projects, :id, :name,
            { selected: @group.projects.map(&:id) }, multiple: true, class: 'select2'

    .col-md-6
      .form-group
        = f.label :due_date, "到期日", class: "control-label"
        .col-sm-10= f.hidden_field :due_date
        .col-sm-10
          .datepicker

  .form-actions
    = f.submit '创建里程碑', class: "btn-create btn"
    = link_to "取消", group_milestones_path(@group), class: "btn btn-cancel"


:javascript
  $.datepicker.regional['zh-CN'] = {
    closeText: '关闭',
    prevText: '&#x3C;上月',
    nextText: '下月&#x3E;',
    currentText: '今天',
    monthNames: ['一月','二月','三月','四月','五月','六月',
    '七月','八月','九月','十月','十一月','十二月'],
    monthNamesShort: ['一月','二月','三月','四月','五月','六月',
    '七月','八月','九月','十月','十一月','十二月'],
    dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
    dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
    dayNamesMin: ['日','一','二','三','四','五','六'],
    weekHeader: '周',
    isRTL: false,
    showMonthAfterYear: true,
    yearSuffix: '年'
  };
  $.datepicker.setDefaults($.datepicker.regional['zh-CN']);
  $(".datepicker").datepicker({
    dateFormat: "yy-mm-dd",
    onSelect: function(dateText, inst) { $("#milestone_due_date").val(dateText) }
  }).datepicker("setDate", $.datepicker.parseDate('yy-mm-dd', $('#milestone_due_date').val()));
